package com.bjtime.hprinter.Fragments.designer

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import com.bjtime.designer.attributes.ViewAttr
import com.bjtime.designer.widget.BaseLabelView


class DesignerPageAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {

    var mFragements     : MutableList<Fragment>     = ArrayList<Fragment> ()
    var ElesFragement      : Eles?                  = null
    var AttrFragement      : Attrs?                 = null
    var OperFragement      : Opes?                  = null
    var SetsFragement      : Sets?                  = null

    init {
        ElesFragement = Eles.newInstance()
        AttrFragement = Attrs.newInstance()
//        OperFragement = Opes.newInstance()
        SetsFragement = Sets.newInstance()

        mFragements.add(ElesFragement as Fragment)
        mFragements.add(AttrFragement as Fragment)
//        mFragements.add(OperFragement as Fragment)
        mFragements.add(SetsFragement as Fragment)
    }

    fun setSelect (type : ViewAttr.VIEW_TYPE) {
        AttrFragement!!.setSelect (type)
    }

    override fun getItem(position: Int): Fragment {
        return mFragements?.get(position)
    }

    override fun getCount(): Int {
        return mFragements?.size
    }


    fun setOnEleClickListener (l: Eles.OnEleClickListener) {
        ElesFragement!!.setOnEleClickListener (l)
    }

    fun setOnSetClickListener (l: Sets.OnSetClickListener) {
        SetsFragement!!.setOnSetClickListener (l)
    }

    fun setView (v : BaseLabelView) {
        AttrFragement!!.setView (v)
    }

}